#include "IUTSCKernel.hpp"
#include "UTSCImpl.hpp"

using namespace NNU::UTSC::Base;
using namespace NNU::UTSC::Kernel;
using namespace NNU::UTSC::Kernel::Time;

IUTSCKernel* pKernel = nullptr;

extern "C" UTSC_KERNEL_API IUTSCKernel* CreateKernelObj()
{
    if (pKernel != nullptr)
        pKernel = nullptr;

    pKernel = new UTSCImpl();
    return pKernel;
}

/// <summary>
/// 销毁GridKernel类对象
/// </summary>
/// <param name="pKernel"></param>
extern "C" UTSC_KERNEL_API  void DestroyKernelObj(IUTSCKernel * pKernel)
{
    if (pKernel != nullptr)
        pKernel->release();

    delete pKernel;
    pKernel = nullptr;
}

//用于转为python版而实现的接口
bool IUTSCKernel::encode(UTSCTime &time,UTSCElementCode &code)
{
    UTSCElementCode *tempCode=&code;
    return this->encode(&time,tempCode);
}

bool IUTSCKernel::decode(UTSCElementCode &code, UTSCTime &time)
{
    UTSCTime *tempTime=&time;
    return this->decode(&code,tempTime);;
}

bool IUTSCKernel::structQuery(UTSCStructType topoType, UTSCElementCode &code, TimeElementCodeStruct &result)
{
    int size;
    structQuery(topoType,&code, result._data, size);
    result._size = size;
    return true;
}

UTSCTopoType IUTSCKernel::topoQuery(TimeElementCodeStruct &code1, TimeElementCodeStruct &code2, int type)
{
    return this->topoQuery(code1._data,code2._data,type);
}